package operations;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class AddOperation implements IOperation{
    @Override
    public void work(BookList books) {
        if(books.fill()){
            System.out.println("书架已满，无法添加");
            return;
        }
        System.out.println("请输入您要添加的书名，作者，类型以及售价");
        Scanner scanner=new Scanner(System.in);
        String name=scanner.nextLine();
        String autor=scanner.nextLine();
        String type=scanner.nextLine();
        int price=scanner.nextInt();
        Book book=new Book(name,price,autor,type);
        int size= books.getUsedSize();
        books.setBooks(size,book);
        books.setUsedSize(size+1);
        System.out.println("添加成功");
    }
}
